package com.pkx.guide.info.service.impl;

import com.pkx.guide.info.entity.TInfoGuideSchemeDetail;
import com.pkx.guide.info.mapper.TInfoGuideSchemeDetailMapper;
import com.pkx.guide.info.service.TInfoGuideSchemeDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.transaction.annotation.Transactional;

/**
 * 诱导屏方案策略明细表 服务实现类
 *
 * @author sunsy
 * @since 2023-11-16
 */
@Service
public class TInfoGuideSchemeDetailServiceImpl extends ServiceImpl<TInfoGuideSchemeDetailMapper, TInfoGuideSchemeDetail> implements TInfoGuideSchemeDetailService {

    /**
     * 分页列表
     *
     * @param tInfoGuideSchemeDetail
     * @return
     */
    @Override
    public IPage<TInfoGuideSchemeDetail> pageList(Page page, TInfoGuideSchemeDetail tInfoGuideSchemeDetail) {
        LambdaQueryWrapper<TInfoGuideSchemeDetail> lambdaQueryWrapper = new QueryWrapper<TInfoGuideSchemeDetail>().lambda();
        return page(page, lambdaQueryWrapper);
    }

    /**
     * 列表查询
     *
     * @param tInfoGuideSchemeDetail
     * @return
     */
    @Override
    public List<TInfoGuideSchemeDetail> listByEntity(TInfoGuideSchemeDetail tInfoGuideSchemeDetail) {
        LambdaQueryWrapper<TInfoGuideSchemeDetail> lambdaQueryWrapper = new QueryWrapper<TInfoGuideSchemeDetail>().lambda();
        return list(lambdaQueryWrapper);
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @Override
    public TInfoGuideSchemeDetail selectById(Integer id) {
        return getById(id);
    }

    /**
     * 保存
     *
     * @param tInfoGuideSchemeDetail
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveTInfoGuideSchemeDetail(TInfoGuideSchemeDetail tInfoGuideSchemeDetail) {
        return save(tInfoGuideSchemeDetail);
    }

    /**
     * 修改
     *
     * @param tInfoGuideSchemeDetail
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean modify(TInfoGuideSchemeDetail tInfoGuideSchemeDetail) {
        return updateById(tInfoGuideSchemeDetail);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteById(Integer id) {
        if (id == null){
            return false;
        }
        LambdaUpdateWrapper<TInfoGuideSchemeDetail> lambdaUpdateWrapper = new UpdateWrapper<TInfoGuideSchemeDetail>().lambda()
            .eq(TInfoGuideSchemeDetail::getId, id)
            .set(TInfoGuideSchemeDetail::getDelFlg, 1);
        return update(lambdaUpdateWrapper);
    }
}
